﻿@using GigaSite.Web.Classes
@model GigaSite.Web.Models.CategoriesHtmlHelperModel

@if (Model.Categories.Count > 0)
{
    const int itemsPerLine = 3;
    <div class="categories">
        @while (Model.Categories.Count > 0)
        {
            var lineCategories = Model.Categories.Take(itemsPerLine).ToList();
            var number = 0;
            foreach (var lineCategory in lineCategories)
            {
                number++;
                Model.Categories.Remove(lineCategory);
                <div class="category @(number == itemsPerLine ? "noRightMargin" : "")">
                    <div class="categoryTitle">
                        <a href="@String.Format(Model.UrlFormat,lineCategory.Id)">@lineCategory.DisplayName</a>
                    </div>
                    <div class="categoryItemsCount">
                        @lineCategory.GetBusinessCardsCount()
                    </div>
                </div>
            }
        }
        <div class="clearfix"></div>
    </div>    
}